home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-02 / tcp-ip.zip / TCPIP.TXT < prev   
Text File  |  1993-04-24  |  91KB  |  1,704 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11.  
  12.                              Introduction
  13.                                   to
  14.                         the Internet Protocols
  15.  
  16.  
  17.  
  18.  
  19.  
  20.                       C                       R
  21.  
  22.                               C       S
  23.                   Computer Science Facilities Group
  24.                               C       I
  25.  
  26.                       L                       S
  27.  
  28.  
  29.                                RUTGERS
  30.                   The State University of New Jersey
  31.  
  32.  
  33.  
  34.  
  35.                              3 July 1987
  36.  
  37. This is an introduction to the Internet networking protocols (TCP/IP).
  38. It  includes  a  summary  of  the  facilities  available   and   brief
  39. descriptions of the major protocols in the family.
  40.  
  41. Copyright  (C)  1987,  Charles  L. Hedrick.  Anyone may reproduce this
  42. document, in whole or in  part,  provided  that:    (1)  any  copy  or
  43. republication  of  the entire document must show Rutgers University as
  44. the source, and must include this notice; and (2)  any  other  use  of
  45. this  material  must reference this manual and Rutgers University, and
  46. the fact that the material is copyright by Charles Hedrick and is used
  47. by permission.
  48.  
  49.  
  50.  
  51. Unix is a trademark of AT&T Technologies, Inc.
  52.  
  53.  
  54.  
  55.                           Table of Contents
  56.  
  57.  
  58.    1. What is TCP/IP?                                                1
  59.    2. General description of the TCP/IP protocols                    5
  60.        2.1 The TCP level                                             7
  61.        2.2 The IP level                                             10
  62.        2.3 The Ethernet level                                       11
  63.    3. Well-known sockets and the applications layer                 12
  64.        3.1 An example application: SMTP                             15
  65.    4. Protocols other than TCP: UDP and ICMP                        17
  66.    5. Keeping track of names and information: the domain system     18
  67.    6. Routing                                                       20
  68.    7. Details about Internet addresses: subnets and broadcasting    21
  69.    8. Datagram fragmentation and reassembly                         23
  70.    9. Ethernet encapsulation: ARP                                   24
  71.    10. Getting more information                                     25
  72.  
  73.  
  74.  
  75.  
  76.  
  77.  
  78.  
  79.  
  80.  
  81.  
  82.  
  83.  
  84.  
  85.  
  86.  
  87.  
  88.  
  89.  
  90.  
  91.  
  92.  
  93.  
  94.  
  95.  
  96.  
  97.  
  98.  
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.                                   i
  111.  
  112.  
  113.  
  114. This document is a brief introduction to TCP/IP, followed by advice on
  115. what to read for more information.  This  is  not  intended  to  be  a
  116. complete  description.    It  can  give  you  a reasonable idea of the
  117. capabilities of the protocols.  But if you need to know any details of
  118. the  technology,  you  will  want  to  read  the  standards  yourself.
  119. Throughout the text, you will find references to the standards, in the
  120. form of "RFC" or "IEN" numbers.  These are document numbers. The final
  121. section of this  document  tells  you  how  to  get  copies  of  those
  122. standards.
  123.  
  124.  
  125.  
  126. 1. What is TCP/IP?
  127.  
  128.  
  129. TCP/IP  is a set of protocols developed to allow cooperating computers
  130. to share resources across a network.  It was developed by a  community
  131. of  researchers centered around the ARPAnet.  Certainly the ARPAnet is
  132. the best-known TCP/IP network.  However as of June, 87, at  least  130
  133. different  vendors  had products that support TCP/IP, and thousands of
  134. networks of all kinds use it.
  135.  
  136. First some basic definitions.  The most accurate name for the  set  of
  137. protocols we are describing is the "Internet protocol suite".  TCP and
  138. IP are two of the protocols in this suite.  (They  will  be  described
  139. below.)    Because  TCP and IP are the best known of the protocols, it
  140. has become common to use the term TCP/IP or IP/TCP  to  refer  to  the
  141. whole  family.  It is probably not worth fighting this habit.  However
  142. this can lead to some oddities.  For example, I  find  myself  talking
  143. about  NFS as being based on TCP/IP, even though it doesn't use TCP at
  144. all.  (It does use IP.  But it  uses  an  alternative  protocol,  UDP,
  145. instead  of TCP.  All of this alphabet soup will be unscrambled in the
  146. following pages.)
  147.  
  148. The Internet is a  collection  of  networks,  including  the  Arpanet,
  149. NSFnet, regional networks such as NYsernet, local networks at a number
  150. of University and research institutions,  and  a  number  of  military
  151. networks.  The term "Internet" applies to this entire set of networks.
  152. The subset of them that is managed by the  Department  of  Defense  is
  153. referred  to  as the "DDN" (Defense Data Network).  This includes some
  154. research-oriented networks, such as  the  Arpanet,  as  well  as  more
  155. strictly  military  ones.    (Because much of the funding for Internet
  156. protocol developments is done via  the  DDN  organization,  the  terms
  157. Internet  and  DDN  can  sometimes  seem  equivalent.)    All of these
  158. networks are connected to each other.  Users can  send  messages  from
  159. any  of  them  to  any other, except where there are security or other
  160. policy restrictions on access.    Officially  speaking,  the  Internet
  161. protocol  documents  are  simply  standards  adopted  by  the Internet
  162. community for its own use.  More recently, the Department  of  Defense
  163. issued a MILSPEC definition of TCP/IP.  This was intended to be a more
  164. formal definition, appropriate for use in  purchasing  specifications.
  165. However  most  of  the  TCP/IP community continues to use the Internet
  166. standards.  The MILSPEC version is intended to be consistent with it.
  167.  
  168. Whatever it is called, TCP/IP is a family of protocols.  A few provide
  169.                                   1
  170.  
  171.  
  172.  
  173. "low-level" functions needed for many applications.  These include IP,
  174. TCP, and UDP.  (These will be described in a bit more  detail  later.)
  175. Others are protocols for doing specific tasks, e.g. transferring files
  176. between computers, sending mail, or finding out who is  logged  in  on
  177. another   computer.      Initially  TCP/IP  was  used  mostly  between
  178. minicomputers or mainframes.  These machines had their own disks,  and
  179. generally  were self-contained.  Thus the most important "traditional"
  180. TCP/IP services are:
  181.  
  182.    - file transfer.  The file transfer protocol (FTP) allows a user on
  183.      any computer to get files from another computer, or to send files
  184.      to another computer.  Security is handled by requiring  the  user
  185.      to  specify  a  user  name  and  password for the other computer.
  186.      Provisions are made for handling file transfer  between  machines
  187.      with different character set, end of line conventions, etc.  This
  188.      is not quite the same thing as more recent "network file  system"
  189.      or  "netbios"  protocols, which will be described below.  Rather,
  190.      FTP is a utility that you run any time you want to access a  file
  191.      on  another  system.    You  use  it to copy the file to your own
  192.      system.  You then work with the local copy.   (See  RFC  959  for
  193.      specifications for FTP.)
  194.  
  195.    - remote  login.    The network terminal protocol (TELNET) allows a
  196.      user to log in on any other computer on the network.  You start a
  197.      remote session by specifying a computer to connect to.  From that
  198.      time until you finish the session, anything you type is  sent  to
  199.      the  other  computer.   Note that you are really still talking to
  200.      your own computer.  But the telnet program effectively makes your
  201.      computer invisible while it is running.  Every character you type
  202.      is sent directly to the other system.  Generally, the  connection
  203.      to  the  remote  computer  behaves much like a dialup connection.
  204.      That is, the remote system will ask you to  log  in  and  give  a
  205.      password, in whatever manner it would normally ask a user who had
  206.      just dialed it up.  When you log off of the other  computer,  the
  207.      telnet  program exits, and you will find yourself talking to your
  208.      own computer.  Microcomputer implementations of telnet  generally
  209.      include  a  terminal  emulator  for some common type of terminal.
  210.      (See RFC's 854 and 855 for specifications for  telnet.    By  the
  211.      way,  the  telnet protocol should not be confused with Telenet, a
  212.      vendor of commercial network services.)
  213.  
  214.    - computer mail.  This allows you to  send  messages  to  users  on
  215.      other  computers.    Originally, people tended to use only one or
  216.      two specific computers.  They  would  maintain  "mail  files"  on
  217.      those machines.  The computer mail system is simply a way for you
  218.      to add a message to another user's mail file.    There  are  some
  219.      problems  with  this  in  an environment where microcomputers are
  220.      used.  The most serious is that a micro is  not  well  suited  to
  221.      receive  computer  mail.    When you send mail, the mail software
  222.      expects to be able  to  open  a  connection  to  the  addressee's
  223.      computer, in order to send the mail.  If this is a microcomputer,
  224.      it may be turned off, or it may be running an  application  other
  225.      than  the mail system.  For this reason, mail is normally handled
  226.      by a larger system, where it is practical to have a  mail  server
  227.      running all the time.  Microcomputer mail software then becomes a
  228.                                   2
  229.  
  230.  
  231.  
  232.      user interface that retrieves mail from the mail  server.    (See
  233.      RFC  821  and  822 for specifications for computer mail.  See RFC
  234.      937 for a protocol designed for microcomputers to use in  reading
  235.      mail from a mail server.)
  236.  
  237. These  services  should  be  present  in any implementation of TCP/IP,
  238. except that micro-oriented implementations may  not  support  computer
  239. mail.  These traditional applications still play a very important role
  240. in TCP/IP-based networks.  However more recently,  the  way  in  which
  241. networks  are  used has been changing.  The older model of a number of
  242. large, self-sufficient computers is beginning to  change.    Now  many
  243. installations    have    several   kinds   of   computers,   including
  244. microcomputers, workstations, minicomputers, and  mainframes.    These
  245. computers  are  likely  to be configured to perform specialized tasks.
  246. Although people are still likely to work with one  specific  computer,
  247. that  computer  will  call on other systems on the net for specialized
  248. services.  This has  led  to  the  "server/client"  model  of  network
  249. services.    A server is a system that provides a specific service for
  250. the rest of the network.  A client is another system  that  uses  that
  251. service.    (Note  that the server and client need not be on different
  252. computers.  They could be  different  programs  running  on  the  same
  253. computer.)    Here  are  the  kinds  of servers typically present in a
  254. modern computer setup.  Note that these computer services can  all  be
  255. provided within the framework of TCP/IP.
  256.  
  257.    - network  file  systems.   This allows a system to access files on
  258.      another computer in a somewhat more  closely  integrated  fashion
  259.      than FTP.  A network file system provides the illusion that disks
  260.      or other devices from one system are directly connected to  other
  261.      systems.    There  is no need to use a special network utility to
  262.      access a file on another system.  Your computer simply thinks  it
  263.      has  some  extra disk drives.  These extra "virtual" drives refer
  264.      to the other system's disks.    This  capability  is  useful  for
  265.      several different purposes.  It lets you put large disks on a few
  266.      computers, but still give others access to the disk space.  Aside
  267.      from the obvious economic benefits, this allows people working on
  268.      several computers  to  share  common  files.    It  makes  system
  269.      maintenance  and  backup  easier, because you don't have to worry
  270.      about updating  and  backing  up  copies  on  lots  of  different
  271.      machines.    A  number  of  vendors  now  offer  high-performance
  272.      diskless computers.  These computers have no disk drives at  all.
  273.      They  are  entirely dependent upon disks attached to common "file
  274.      servers".   (See  RFC's  1001  and  1002  for  a  description  of
  275.      PC-oriented   NetBIOS   over   TCP.     In  the  workstation  and
  276.      minicomputer area, Sun's Network File System is more likely to be
  277.      used.    Protocol  specifications  for  it are available from Sun
  278.      Microsystems.)
  279.  
  280.    - remote printing.  This allows you to  access  printers  on  other
  281.      computers  as if they were directly attached to yours.  (The most
  282.      commonly used protocol is the remote  lineprinter  protocol  from
  283.      Berkeley  Unix.  Unfortunately, there is no protocol document for
  284.      this.  However the C code is easily obtained  from  Berkeley,  so
  285.      implementations are common.)
  286.  
  287.                                   3
  288.  
  289.  
  290.  
  291.    - remote  execution.   This allows you to request that a particular
  292.      program be run on a different computer.  This is useful when  you
  293.      can  do  most  of  your work on a small computer, but a few tasks
  294.      require the resources of a larger system.  There are a number  of
  295.      different  kinds  of remote execution.  Some operate on a command
  296.      by command basis.  That is, you request that a  specific  command
  297.      or  set  of commands should run on some specific computer.  (More
  298.      sophisticated versions will choose a system that  happens  to  be
  299.      free.)    However  there are also "remote procedure call" systems
  300.      that allow a program to  call  a  subroutine  that  will  run  on
  301.      another  computer.    (There  are  many  protocols  of this sort.
  302.      Berkeley Unix contains two servers to execute commands  remotely:
  303.      rsh  and  rexec.   The man pages describe the protocols that they
  304.      use.  The user-contributed software with Berkeley 4.3 contains  a
  305.      "distributed  shell"  that  will  distribute tasks among a set of
  306.      systems, depending upon load.  Remote procedure  call  mechanisms
  307.      have  been  a  topic  for research for a number of years, so many
  308.      organizations have implementations of such facilities.  The  most
  309.      widespread commercially-supported remote procedure call protocols
  310.      seem to be Xerox's Courier and Sun's RPC.  Protocol documents are
  311.      available  from  Xerox and Sun.  There is a public implementation
  312.      of Courier over TCP as part of the user-contributed software with
  313.      Berkeley  4.3.   An implementation of RPC was posted to Usenet by
  314.      Sun, and also appears as part of  the  user-contributed  software
  315.      with Berkeley 4.3.)
  316.  
  317.    - name  servers.    In  large  installations, there are a number of
  318.      different collections of names that have to  be  managed.    This
  319.      includes  users  and their passwords, names and network addresses
  320.      for computers, and accounts.  It becomes  very  tedious  to  keep
  321.      this data up to date on all of the computers.  Thus the databases
  322.      are kept on a small number of systems.  Other systems access  the
  323.      data over the network.  (RFC 822 and 823 describe the name server
  324.      protocol used to keep track of host names and Internet  addresses
  325.      on  the  Internet.    This  is  now a required part of any TCP/IP
  326.      implementation.  IEN 116 describes an older name server  protocol
  327.      that is used by a few terminal servers and other products to look
  328.      up host names.  Sun's  Yellow  Pages  system  is  designed  as  a
  329.      general  mechanism to handle user names, file sharing groups, and
  330.      other databases commonly used by Unix  systems.    It  is  widely
  331.      available  commercially.    Its  protocol definition is available
  332.      from Sun.)
  333.  
  334.    - terminal servers.  Many installations no longer connect terminals
  335.      directly  to  computers.    Instead they connect them to terminal
  336.      servers.  A terminal server is simply a small computer that  only
  337.      knows  how  to  run  telnet  (or some other protocol to do remote
  338.      login).  If your terminal is  connected  to  one  of  these,  you
  339.      simply  type the name of a computer, and you are connected to it.
  340.      Generally it is possible to have active connections to more  than
  341.      one  computer  at  the  same time.  The terminal server will have
  342.      provisions to switch between connections rapidly, and  to  notify
  343.      you  when  output  is  waiting for another connection.  (Terminal
  344.      servers use the telnet protocol, already mentioned.  However  any
  345.      real terminal server will also have to support name service and a
  346.                                   4
  347.  
  348.  
  349.  
  350.      number of other protocols.)
  351.  
  352.    - network-oriented  window  systems.      Until   recently,   high-
  353.      performance  graphics  programs had to execute on a computer that
  354.      had  a  bit-mapped  graphics  screen  directly  attached  to  it.
  355.      Network  window  systems  allow  a  program to use a display on a
  356.      different computer.  Full-scale network window systems provide an
  357.      interface  that  lets you distribute jobs to the systems that are
  358.      best  suited  to  handle  them,  but  still  give  you  a  single
  359.      graphically-based  user  interface.  (The most widely-implemented
  360.      window system is X. A  protocol  description  is  available  from
  361.      MIT's  Project  Athena.  A reference implementation is publically
  362.      available from MIT.  A number  of  vendors  are  also  supporting
  363.      NeWS,  a window system defined by Sun.  Both of these systems are
  364.      designed to use TCP/IP.)
  365.  
  366. Note that some of the  protocols  described  above  were  designed  by
  367. Berkeley,  Sun,  or other organizations.  Thus they are not officially
  368. part of the Internet protocol suite.   However  they  are  implemented
  369. using  TCP/IP, just as normal TCP/IP application protocols are.  Since
  370. the protocol definitions are not  considered  proprietary,  and  since
  371. commercially-support  implementations  are  widely  available,  it  is
  372. reasonable to think of these protocols as being  effectively  part  of
  373. the  Internet  suite.   Note that the list above is simply a sample of
  374. the sort of services  available  through  TCP/IP.    However  it  does
  375. contain   the  majority  of  the  "major"  applications.    The  other
  376. commonly-used protocols tend to be specialized facilities for  getting
  377. information  of  various  kinds, such as who is logged in, the time of
  378. day, etc.  However if you need a facility that is not listed here,  we
  379. encourage  you  to  look  through  the  current  edition  of  Internet
  380. Protocols (currently RFC 1011),  which  lists  all  of  the  available
  381. protocols,   and   also   to   look   at  some  of  the  major  TCP/IP
  382. implementations to see what various vendors have added.
  383.  
  384.  
  385.  
  386. 2. General description of the TCP/IP protocols
  387.  
  388.  
  389. TCP/IP is a layered set of protocols.  In  order  to  understand  what
  390. this  means,  it is useful to look at an example.  A typical situation
  391. is sending mail.  First, there is a protocol for mail.  This defines a
  392. set  of  commands which one machine sends to another, e.g. commands to
  393. specify who the sender of the message is, who it is being sent to, and
  394. then  the  text  of  the  message.  However this protocol assumes that
  395. there is a way to communicate  reliably  between  the  two  computers.
  396. Mail,  like  other  application  protocols,  simply  defines  a set of
  397. commands and messages to be sent.  It is designed to be used  together
  398. with  TCP and IP. TCP is responsible for making sure that the commands
  399. get through to the other end.  It keeps track of  what  is  sent,  and
  400. retransmitts anything that did not get through.  If any message is too
  401. large for one datagram, e.g. the text of the mail, TCP will  split  it
  402. up  into  several  datagrams,  and  make  sure  that  they  all arrive
  403. correctly.  Since these functions are needed  for  many  applications,
  404. they are put together into a separate protocol, rather than being part
  405.                                   5
  406.  
  407.  
  408.  
  409. of the specifications for sending mail.   You  can  think  of  TCP  as
  410. forming a library of routines that applications can use when they need
  411. reliable network communications with another computer.  Similarly, TCP
  412. calls  on the services of IP.  Although the services that TCP supplies
  413. are needed by  many  applications,  there  are  still  some  kinds  of
  414. applications  that  don't  need them.  However there are some services
  415. that every application needs.  So these services are put together into
  416. IP.    As  with TCP, you can think of IP as a library of routines that
  417. TCP calls on, but which is also available to applications  that  don't
  418. use  TCP.    This  strategy  of building several levels of protocol is
  419. called "layering".  We think of  the  applications  programs  such  as
  420. mail,  TCP, and IP, as being separate "layers", each of which calls on
  421. the services of the layer below it.   Generally,  TCP/IP  applications
  422. use 4 layers:
  423.  
  424.    - an application protocol such as mail
  425.  
  426.    - a  protocol  such  as  TCP  that  provides  services need by many
  427.      applications
  428.  
  429.    - IP, which provides the basic  service  of  getting  datagrams  to
  430.      their destination
  431.  
  432.    - the  protocols  needed to manage a specific physical medium, such
  433.      as Ethernet or a point to point line.
  434.  
  435. TCP/IP is based on the "catenet model".  (This is  described  in  more
  436. detail  in  IEN 48.)  This model assumes that there are a large number
  437. of independent networks connected together  by  gateways.    The  user
  438. should  be able to access computers or other resources on any of these
  439. networks.   Datagrams  will  often  pass  through  a  dozen  different
  440. networks  before  getting  to  their  final  destination.  The routing
  441. needed to accomplish this should be completely invisible to the  user.
  442. As  far  as  the  user  is concerned, all he needs to know in order to
  443. access another system is an "Internet address".  This  is  an  address
  444. that looks like 128.6.4.194.  It is actually a 32-bit number.  However
  445. it is normally written as 4 decimal numbers, each representing 8  bits
  446. of  the  address.  (The term "octet" is used by Internet documentation
  447. for such 8-bit chunks.  The term "byte" is not used, because TCP/IP is
  448. supported  by  some computers that have byte sizes other than 8 bits.)
  449. Generally the structure of the  address  gives  you  some  information
  450. about  how  to  get  to  the  system.  For example, 128.6 is a network
  451. number assigned by a central authority to Rutgers University.  Rutgers
  452. uses  the  next  octet  to  indicate  which of the campus Ethernets is
  453. involved.  128.6.4 happens to be an  Ethernet  used  by  the  Computer
  454. Science  Department.    The last octet allows for up to 254 systems on
  455. each Ethernet.  (It is 254 because 0 and  255  are  not  allowed,  for
  456. reasons  that  will  be  discussed  later.)  Note that 128.6.4.194 and
  457. 128.6.5.194 would be different systems.  The structure of an  Internet
  458. address is described in a bit more detail later.
  459.  
  460. Of  course  we  normally  refer  to  systems  by  name, rather than by
  461. Internet address.  When we specify a name, the network software  looks
  462. it  up  in  a  database,  and comes up with the corresponding Internet
  463. address.  Most of the network software deals strictly in terms of  the
  464.                                   6
  465.  
  466.  
  467.  
  468. address.  (RFC 882 describes the name server technology used to handle
  469. this lookup.)
  470.  
  471. TCP/IP is  built  on  "connectionless"  technology.    Information  is
  472. transfered  as  a sequence of "datagrams".  A datagram is a collection
  473. of data that is sent as a single message.  Each of these datagrams  is
  474. sent  through  the network individually.  There are provisions to open
  475. connections (i.e.  to start a conversation that will continue for some
  476. time).    However at some level, information from those connections is
  477. broken up into datagrams, and  those  datagrams  are  treated  by  the
  478. network  as  completely  separate.    For example, suppose you want to
  479. transfer a 15000 octet file.  Most networks can't handle a 15000 octet
  480. datagram.   So the protocols will break this up into something like 30
  481. 500-octet datagrams.  Each of these datagrams  will  be  sent  to  the
  482. other  end.    At  that point, they will be put back together into the
  483. 15000-octet file.  However while those datagrams are in  transit,  the
  484. network doesn't know that there is any connection between them.  It is
  485. perfectly possible  that  datagram  14  will  actually  arrive  before
  486. datagram  13.    It is also possible that somewhere in the network, an
  487. error will occur, and some datagram won't get through at all.  In that
  488. case, that datagram has to be sent again.
  489.  
  490. Note  by  the way that the terms "datagram" and "packet" often seem to
  491. be nearly interchangable.  Technically, datagram is the right word  to
  492. use  when  describing  TCP/IP.  A datagram is a unit of data, which is
  493. what the protocols deal with.  A packet is a physical thing, appearing
  494. on an Ethernet or some wire.  In most cases a packet simply contains a
  495. datagram, so there is  very  little  difference.    However  they  can
  496. differ.  When TCP/IP is used on top of X.25, the X.25 interface breaks
  497. the datagrams up into 128-byte packets.   This  is  invisible  to  IP,
  498. because  the  packets  are put back together into a single datagram at
  499. the other end before being processed by TCP/IP.  So in this case,  one
  500. IP  datagram  would  be carried by several packets.  However with most
  501. media, there are efficiency advantages to  sending  one  datagram  per
  502. packet, and so the distinction tends to vanish.
  503.  
  504.  
  505.  
  506. 2.1 The TCP level
  507.  
  508.  
  509. Two separate protocols are involved in handling TCP/IP datagrams.  TCP
  510. (the "transmission control protocol") is responsible for  breaking  up
  511. the  message  into  datagrams,  reassembling  them  at  the other end,
  512. resending anything that gets lost, and  putting  things  back  in  the
  513. right  order.  IP (the "internet protocol") is responsible for routing
  514. individual datagrams.  It may seem like TCP is  doing  all  the  work.
  515. And  in  small networks that is true.  However in the Internet, simply
  516. getting a datagram to its  destination  can  be  a  complex  job.    A
  517. connection  may require the datagram to go through several networks at
  518. Rutgers, a serial line to the John von Neuman Supercomputer Center,  a
  519. couple  of Ethernets there, a series of 56Kbaud phone lines to another
  520. NSFnet site, and more Ethernets on another campus.  Keeping  track  of
  521. the  routes  to all of the destinations and handling incompatibilities
  522. among different transport media turns out to be a complex job.    Note
  523.                                   7
  524.  
  525.  
  526.  
  527. that  the  interface  between TCP and IP is fairly simple.  TCP simply
  528. hands IP a datagram with a destination.   IP  doesn't  know  how  this
  529. datagram relates to any datagram before it or after it.
  530.  
  531. It  may  have occurred to you that something is missing here.  We have
  532. talked about Internet addresses, but not about how you keep  track  of
  533. multiple  connections  to  a given system.  Clearly it isn't enough to
  534. get a datagram to the right  destination.    TCP  has  to  know  which
  535. connection  this  datagram  is  part  of.  This task is referred to as
  536. "demultiplexing."  In fact, there are several levels of demultiplexing
  537. going  on in TCP/IP.  The information needed to do this demultiplexing
  538. is contained in a series of "headers".  A header is simply a few extra
  539. octets  tacked  onto  the  beginning of a datagram by some protocol in
  540. order to keep track of it.  It's a lot like putting a letter  into  an
  541. envelope  and  putting  an  address  on  the  outside of the envelope.
  542. Except with modern networks it happens several times.  It's  like  you
  543. put the letter into a little envelope, your secretary puts that into a
  544. somewhat bigger envelope, the campus mail center  puts  that  envelope
  545. into a still bigger one, etc.  Here is an overview of the headers that
  546. get stuck on a message that passes through a typical TCP/IP network:
  547.  
  548. We start with a single data stream, say a file you are trying to  send
  549. to some other computer:
  550.  
  551.    ......................................................
  552.  
  553. TCP  breaks  it  up into manageable chunks.  (In order to do this, TCP
  554. has to know how large a datagram your network can handle.    Actually,
  555. the TCP's at each end say how big a datagram they can handle, and then
  556. they pick the smallest size.)
  557.  
  558.    ....   ....   ....   ....   ....   ....   ....   ....
  559.  
  560. TCP puts a header at the front of each datagram.  This header actually
  561. contains  at least 20 octets, but the most important ones are a source
  562. and destination "port number" and  a  "sequence  number".    The  port
  563. numbers  are used to keep track of different conversations.  Suppose 3
  564. different people are transferring files.  Your TCP might allocate port
  565. numbers 1000, 1001, and 1002 to these transfers.  When you are sending
  566. a datagram, this becomes the "source" port number, since you  are  the
  567. source  of  the  datagram.    Of  course  the TCP at the other end has
  568. assigned a port number of its own for the conversation.  Your TCP  has
  569. to  know the port number used by the other end as well.  (It finds out
  570. when the connection starts, as we will explain below.)  It  puts  this
  571. in  the  "destination" port field.  Of course if the other end sends a
  572. datagram back to you, the source and destination port numbers will  be
  573. reversed,  since  then  it  will  be  the  source  and you will be the
  574. destination.  Each datagram has a sequence number.  This  is  used  so
  575. that  the  other  end  can make sure that it gets the datagrams in the
  576. right  order,  and  that  it  hasn't  missed  any.    (See   the   TCP
  577. specification for details.)  TCP doesn't number the datagrams, but the
  578. octets.  So if there are 500 octets of  data  in  each  datagram,  the
  579. first datagram might be numbered 0, the second 500, the next 1000, the
  580. next 1500, etc.  Finally, I will mention the  Checksum.    This  is  a
  581. number  that  is  computed by adding up all the octets in the datagram
  582.                                   8
  583.  
  584.  
  585.  
  586. (more or less - see the TCP spec).  The result is put in  the  header.
  587. TCP  at  the other end computes the checksum again.  If they disagree,
  588. then something bad happened to the datagram in transmission, and it is
  589. thrown away.  So here's what the datagram looks like now.
  590.  
  591.     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  592.     ]          Source Port          ]       Destination Port        ]
  593.     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  594.     ]                        Sequence Number                        ]
  595.     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  596.     ]                    Acknowledgment Number                      ]
  597.     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  598.     ]  Data ]           ]U]A]P]R]S]F]                               ]
  599.     ] Offset] Reserved  ]R]C]S]S]Y]I]            Window             ]
  600.     ]       ]           ]G]K]H]T]N]N]                               ]
  601.     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  602.     ]           Checksum            ]         Urgent Pointer        ]
  603.     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  604.     ]   your data ... next 500 octets                               ]
  605.     ]   ......                                                      ]
  606.  
  607. If  we abbreviate the TCP header as "T", the whole file now looks like
  608. this:
  609.  
  610.    T....   T....   T....   T....   T....   T....   T....
  611.  
  612. You will note that there are items in  the  header  that  I  have  not
  613. described  above.    They  are  generally  involved  with managing the
  614. connection.  In order to make sure the datagram  has  arrived  at  its
  615. destination,  the  recipient  has  to  send back an "acknowledgement".
  616. This is a datagram whose "Acknowledgement number" field is filled  in.
  617. For  example,  sending  a  packet  with  an  acknowledgement  of  1500
  618. indicates that you have received all the data up to octet number 1500.
  619. If  the  sender  doesn't  get  an  acknowledgement within a reasonable
  620. amount of time, it sends the data  again.    The  window  is  used  to
  621. control  how  much  data can be in transit at any one time.  It is not
  622. practical to wait for each datagram to be acknowledged before  sending
  623. the  next  one.    That would slow things down too much.  On the other
  624. hand, you can't just keep sending, or a fast  computer  might  overrun
  625. the  capacity  of  a slow one to absorb data.  Thus each end indicates
  626. how much new data it is currently prepared to absorb  by  putting  the
  627. number  of  octets  in  its  "Window" field.  As the computer receives
  628. data, the amount of space left in its window decreases.  When it  goes
  629. to  zero, the sender has to stop.  As the receiver processes the data,
  630. it increases its window, indicating that it is ready  to  accept  more
  631. data.  Often the same datagram can be used to acknowledge receipt of a
  632. set of data and to give permission for  additional  new  data  (by  an
  633. updated  window).  The "Urgent" field allows one end to tell the other
  634. to skip ahead in its processing to a particular octet.  This is  often
  635. useful  for  handling asynchronous events, for example when you type a
  636. control character or other command that interrupts output.  The  other
  637. fields are beyond the scope of this document.
  638.  
  639.  
  640.  
  641.                                   9
  642.  
  643.  
  644.  
  645. 2.2 The IP level
  646.  
  647.  
  648. TCP  sends each of these datagrams to IP.  Of course it has to tell IP
  649. the Internet address of the computer at the other end.  Note that this
  650. is  all  IP  is concerned about.  It doesn't care about what is in the
  651. datagram, or even in the TCP header.  IP's job is  simply  to  find  a
  652. route for the datagram and get it to the other end.  In order to allow
  653. gateways or other intermediate systems to  forward  the  datagram,  it
  654. adds  its  own  header.  The main things in this header are the source
  655. and destination Internet address (32-bit addresses, like 128.6.4.194),
  656. the  protocol  number,  and  another  checksum.    The source Internet
  657. address is simply the address of your machine.  (This is necessary  so
  658. the  other  end  knows where the datagram came from.)  The destination
  659. Internet address is the address  of  the  other  machine.    (This  is
  660. necessary  so  any  gateways  in  the  middle  know where you want the
  661. datagram to go.)  The protocol number tells IP at  the  other  end  to
  662. send  the  datagram  to TCP.  Although most IP traffic uses TCP, there
  663. are other protocols that can use IP, so you  have  to  tell  IP  which
  664. protocol  to send the datagram to.  Finally, the checksum allows IP at
  665. the other end to verify that the header  wasn't  damaged  in  transit.
  666. Note  that TCP and IP have separate checksums.  IP needs to be able to
  667. verify that the header didn't get damaged in transit, or it could send
  668. a  message to the wrong place.  For reasons not worth discussing here,
  669. it is both more efficient and safer to have  TCP  compute  a  separate
  670. checksum  for  the  TCP  header  and  data.  Once IP has tacked on its
  671. header, here's what the message looks like:
  672.  
  673.     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  674.     ]Version]  IHL  ]Type of Service]          Total Length         ]
  675.     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  676.     ]         Identification        ]Flags]      Fragment Offset    ]
  677.     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  678.     ]  Time to Live ]    Protocol   ]         Header Checksum       ]
  679.     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  680.     ]                       Source Address                          ]
  681.     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  682.     ]                    Destination Address                        ]
  683.     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  684.     ]  TCP header, then your data ......                            ]
  685.     ]                                                               ]
  686.  
  687. If we represent the IP header by an "I",  your  file  now  looks  like
  688. this:
  689.  
  690.    IT....   IT....   IT....   IT....   IT....   IT....   IT....
  691.  
  692. Again,  the  header contains some additional fields that have not been
  693. discussed.  Most of them are beyond the scope of this document.    The
  694. flags  and fragment offset are used to keep track of the pieces when a
  695. datagram has to be split up.   This  can  happen  when  datagrams  are
  696. forwarded through a network for which they are too big.  (This will be
  697. discussed a bit more below.)  The time to live is  a  number  that  is
  698. decremented  whenever  the  datagram passes through a system.  When it
  699. goes to zero, the datagram is discarded.  This is done in case a  loop
  700.                                   10
  701.  
  702.  
  703.  
  704. develops  in the system somehow.  Of course this should be impossible,
  705. but  well-designed  networks  are  built  to  cope  with  "impossible"
  706. conditions.
  707.  
  708. At this point, it's possible that no more headers are needed.  If your
  709. computer happens to have a direct phone  line  connecting  it  to  the
  710. destination  computer,  or  to  a  gateway,  it  may  simply  send the
  711. datagrams out on the line (though likely a synchronous  protocol  such
  712. as  HDLC  would be used, and it would add at least a few octets at the
  713. beginning and end).
  714.  
  715.  
  716.  
  717. 2.3 The Ethernet level
  718.  
  719.  
  720. However most of our networks these days use Ethernet.  So now we  have
  721. to  describe  Ethernet's headers.  Unfortunately, Ethernet has its own
  722. addresses.  The people who designed Ethernet wanted to make sure  that
  723. no  two  machines  would  end  up  with  the  same  Ethernet  address.
  724. Furthermore, they  didn't  want  the  user  to  have  to  worry  about
  725. assigning  addresses.    So  each  Ethernet  controller  comes with an
  726. address builtin from the factory.  In order to  make  sure  that  they
  727. would  never have to reuse addresses, the Ethernet designers allocated
  728. 48 bits for the Ethernet address.  People who make Ethernet  equipment
  729. have  to  register  with  a  central  authority, to make sure that the
  730. numbers they assign don't overlap any other manufacturer.  Ethernet is
  731. a "broadcast medium".  That is, it is in effect like an old party line
  732. telephone.  When you send a packet out on the Ethernet, every  machine
  733. on  the  network sees the packet.  So something is needed to make sure
  734. that the right machine gets it.  As you might guess, this involves the
  735. Ethernet  header.    Every  Ethernet packet has a 14-octet header that
  736. includes the source and destination Ethernet address, and a type code.
  737. Each machine is supposed to pay attention only to packets with its own
  738. Ethernet address in the destination field.  (It's  perfectly  possible
  739. to  cheat,  which  is  one reason that Ethernet communications are not
  740. terribly secure.)  Note  that  there  is  no  connection  between  the
  741. Ethernet address and the Internet address.  Each machine has to have a
  742. table of what Ethernet address corresponds to what  Internet  address.
  743. (We  will  describe  how  this  table is constructed a bit later.)  In
  744. addition to the addresses, the header contains a type code.  The  type
  745. code is to allow for several different protocol families to be used on
  746. the same network.  So you can use TCP/IP, DECnet, Xerox  NS,  etc.  at
  747. the  same  time.   Each of them will put a different value in the type
  748. field.  Finally,  there  is  a  checksum.    The  Ethernet  controller
  749. computes a checksum of the entire packet.  When the other end receives
  750. the packet, it recomputes the checksum, and throws the packet away  if
  751. the  answer  disagrees  with the original.  The checksum is put on the
  752. end of the packet, not in the header.  The final result is  that  your
  753. message looks like this:
  754.  
  755.  
  756.  
  757.  
  758.  
  759.                                   11
  760.  
  761.  
  762.  
  763.     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  764.     ]       Ethernet destination address (first 32 bits)            ]
  765.     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  766.     ] Ethernet dest (last 16 bits)  ]Ethernet source (first 16 bits)]
  767.     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  768.     ]       Ethernet source address (last 32 bits)                  ]
  769.     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  770.     ]        Type code              ]
  771.     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  772.     ]  IP header, then TCP header, then your data                   ]
  773.     ]                                                               ]
  774.         ...
  775.     ]                                                               ]
  776.     ]   end of your data                                            ]
  777.     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  778.     ]                       Ethernet Checksum                       ]
  779.     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  780.  
  781. If  we  represent  the  Ethernet  header  with  "E",  and the Ethernet
  782. checksum with "C", your file now looks like this:
  783.  
  784.    EIT....C   EIT....C   EIT....C   EIT....C   EIT....C
  785.  
  786. When these packets are received by the other end, of  course  all  the
  787. headers  are  removed.    The  Ethernet interface removes the Ethernet
  788. header and the checksum.  It looks at the type code.  Since  the  type
  789. code  is the one assigned to IP, the Ethernet device driver passes the
  790. datagram up to IP.  IP removes the IP header.   It  looks  at  the  IP
  791. protocol  field.    Since  the  protocol  type  is  TCP, it passes the
  792. datagram up to TCP.  TCP now looks at the sequence number.    It  uses
  793. the  sequence  numbers  and  other  information  to  combine  all  the
  794. datagrams into the original file.
  795.  
  796. The ends our initial summary of TCP/IP.  There are still some  crucial
  797. concepts we haven't gotten to, so we'll now go back and add details in
  798. several areas.  (For detailed descriptions of the items discussed here
  799. see,  RFC  793  for  TCP,  RFC  791  for IP, and RFC's 894 and 826 for
  800. sending IP over Ethernet.)
  801.  
  802.  
  803.  
  804. 3. Well-known sockets and the applications layer
  805.  
  806.  
  807. So far, we have described how a stream  of  data  is  broken  up  into
  808. datagrams,  sent  to another computer, and put back together.  However
  809. something more is needed  in  order  to  accomplish  anything  useful.
  810. There  has  to  be  a  way for you to open a connection to a specified
  811. computer, log into it, tell it what file you  want,  and  control  the
  812. transmission  of  the  file.   (If you have a different application in
  813. mind, e.g. computer mail, some analogous protocol is needed.)  This is
  814. done  by  "application  protocols".  The application protocols run "on
  815. top" of TCP/IP.  That is, when they want to send a message, they  give
  816. the  message  to  TCP.   TCP makes sure it gets delivered to the other
  817. end.  Because TCP and IP take care of all the networking details,  the
  818.                                   12
  819.  
  820.  
  821.  
  822. applications  protocols can treat a network connection as if it were a
  823. simple byte stream, like a terminal or phone line.
  824.  
  825. Before going into more details about applications programs, we have to
  826. describe how you find an application.  Suppose you want to send a file
  827. to a computer whose Internet address  is  128.6.4.7.    To  start  the
  828. process,  you  need  more than just the Internet address.  You have to
  829. connect to the FTP server at the  other  end.    In  general,  network
  830. programs  are  specialized  for a specific set of tasks.  Most systems
  831. have separate programs  to  handle  file  transfers,  remote  terminal
  832. logins, mail, etc.  When you connect to 128.6.4.7, you have to specify
  833. that you want to talk to the FTP server.    This  is  done  by  having
  834. "well-known  sockets"  for  each  server.    Recall that TCP uses port
  835. numbers to keep track of  individual  conversations.    User  programs
  836. normally  use more or less random port numbers.  However specific port
  837. numbers are assigned to the programs that sit  waiting  for  requests.
  838. For  example,  if  you  want  to send a file, you will start a program
  839. called "ftp".  It will open a connection using some random number, say
  840. 1234,  for  the  port number on its end.  However it will specify port
  841. number 21 for the other end.  This is the official port number for the
  842. FTP server.  Note that there are two different programs involved.  You
  843. run ftp on your side.  This is a program designed to  accept  commands
  844. from  your  terminal  and  pass them on to the other end.  The program
  845. that you talk to on the other machine  is  the  FTP  server.    It  is
  846. designed  to  accept commands from the network connection, rather than
  847. an interactive terminal.  There is no need for your program to  use  a
  848. well-known  socket  number  for  itself.  Nobody is trying to find it.
  849. However the servers have to have well-known numbers,  so  that  people
  850. can  open  connections  to  them and start sending them commands.  The
  851. official  port  numbers  for  each  program  are  given  in  "Assigned
  852. Numbers".
  853.  
  854. Note  that  a  connection is actually described by a set of 4 numbers:
  855. the Internet address at each end, and the TCP port number at each end.
  856. Every  datagram  has  all  four of those numbers in it.  (The Internet
  857. addresses are in the IP header, and the TCP port numbers  are  in  the
  858. TCP header.)  In order to keep things straight, no two connections can
  859. have the same set of numbers.  However it is enough for any one number
  860. to  be  different.    For  example,  it  is perfectly possible for two
  861. different users on a machine to be sending files  to  the  same  other
  862. machine.    This  could  result  in  connections  with  the  following
  863. parameters:
  864.  
  865.                    Internet addresses         TCP ports
  866.     connection 1  128.6.4.194, 128.6.4.7      1234, 21
  867.     connection 2  128.6.4.194, 128.6.4.7      1235, 21
  868.  
  869. Since the same machines are involved, the Internet addresses  are  the
  870. same.    Since  they  are  both  doing  file transfers, one end of the
  871. connection involves the well-known port number  for  FTP.    The  only
  872. thing  that  differs is the port number for the program that the users
  873. are running.  That's enough of a difference.  Generally, at least  one
  874. end  of  the  connection asks the network software to assign it a port
  875. number that is guaranteed to be unique.   Normally,  it's  the  user's
  876. end, since the server has to use a well-known number.
  877.                                   13
  878.  
  879.  
  880.  
  881. Now  that  we  know  how  to  open  connections, let's get back to the
  882. applications programs.  As mentioned earlier, once TCP  has  opened  a
  883. connection,  we  have  something  that might as well be a simple wire.
  884. All the hard parts are handled by TCP and IP.  However we  still  need
  885. some  agreement  as  to  what we send over this connection.  In effect
  886. this is simply an agreement on what set of  commands  the  application
  887. will  understand,  and  the  format  in  which  they  are  to be sent.
  888. Generally, what is sent is a combination of commands and data.    They
  889. use  context  to  differentiate.  For example, the mail protocol works
  890. like this: Your mail program opens a connection to the mail server  at
  891. the  other end.  Your program gives it your machine's name, the sender
  892. of the message, and the recipients you want it sent to.  It then sends
  893. a  command saying that it is starting the message.  At that point, the
  894. other end  stops  treating  what  it  sees  as  commands,  and  starts
  895. accepting  the  message.  Your end then starts sending the text of the
  896. message.  At the end of the message, a special mark is sent (a dot  in
  897. the first column).  After that, both ends understand that your program
  898. is again sending commands.  This is the simplest way to do things, and
  899. the one that most applications use.
  900.  
  901. File  transfer  is  somewhat more complex.  The file transfer protocol
  902. involves two different connections.  It starts  out  just  like  mail.
  903. The user's program sends commands like "log me in as this user", "here
  904. is my password", "send me the file with this name".  However once  the
  905. command  to  send  data is sent, a second connection is opened for the
  906. data itself.  It would certainly be possible to send the data  on  the
  907. same  connection,  as  mail does.  However file transfers often take a
  908. long time.  The designers of the  file  transfer  protocol  wanted  to
  909. allow  the  user  to  continue  issuing commands while the transfer is
  910. going on.  For example, the user might make an inquiry,  or  he  might
  911. abort  the  transfer.    Thus  the designers felt it was best to use a
  912. separate connection for  the  data  and  leave  the  original  command
  913. connection  for  commands.    (It  is  also  possible  to open command
  914. connections to two different computers, and tell them to send  a  file
  915. from  one  to  the other.  In that case, the data couldn't go over the
  916. command connection.)
  917.  
  918. Remote terminal connections use another mechanism still.   For  remote
  919. logins,  there  is just one connection.  It normally sends data.  When
  920. it is necessary to send a command (e.g. to set the terminal type or to
  921. change  some  mode),  a special character is used to indicate that the
  922. next character is a command.  If the user happens to type that special
  923. character as data, two of them are sent.
  924.  
  925. We  are  not  going to describe the application protocols in detail in
  926. this document.  It's better to read the RFC's yourself.  However there
  927. are  a  couple of common conventions used by applications that will be
  928. described here.  First, the common network representation:  TCP/IP  is
  929. intended  to  be  usable  on  any  computer.    Unfortunately, not all
  930. computers agree on how data is represented.  There are differences  in
  931. character  codes  (ASCII  vs.  EBCDIC),  in  end  of  line conventions
  932. (carriage return, line feed, or a representation using counts), and in
  933. whether  terminals expect characters to be sent individually or a line
  934. at a time.   In  order  to  allow  computers  of  different  kinds  to
  935. communicate,   each   applications   protocol   defines   a   standard
  936.                                   14
  937.  
  938.  
  939.  
  940. representation.    Note  that  TCP  and  IP  do  not  care  about  the
  941. representation.    TCP  simply  sends octets.  However the programs at
  942. both ends have to agree on how the octets are to be interpreted.   The
  943. RFC  for  each  application  specifies the standard representation for
  944. that application.  Normally it  is  "net  ASCII".    This  uses  ASCII
  945. characters,  with end of line denoted by a carriage return followed by
  946. a line feed.  For remote login,  there  is  also  a  definition  of  a
  947. "standard terminal", which turns out to be a half-duplex terminal with
  948. echoing happening on the local machine.  Most applications  also  make
  949. provisions  for  the  two  computers to agree on other representations
  950. that they may find more convenient.  For example, PDP-10's have 36-bit
  951. words.    There  is a way that two PDP-10's can agree to send a 36-bit
  952. binary file.  Similarly, two systems that prefer full-duplex  terminal
  953. conversations  can  agree  on  that.    However each application has a
  954. standard representation, which every machine must support.
  955.  
  956.  
  957.  
  958. 3.1 An example application: SMTP
  959.  
  960.  
  961. In order to give a bit better idea what is involved in the application
  962. protocols,  I'm  going  to  show an example of SMTP, which is the mail
  963. protocol.  (SMTP is "simple mail transfer protocol.)  We assume that a
  964. computer called TOPAZ.RUTGERS.EDU wants to send the following message.
  965.  
  966.   Date: Sat, 27 Jun 87 13:26:31 EDT
  967.   From: hedrick@topaz.rutgers.edu
  968.   To: levy@red.rutgers.edu
  969.   Subject: meeting
  970.  
  971.   Let's get together Monday at 1pm.
  972.  
  973. First,  note  that the format of the message itself is described by an
  974. Internet standard (RFC 822).  The standard specifies the fact that the
  975. message  must be transmitted as net ASCII (i.e. it must be ASCII, with
  976. carriage return/linefeed to delimit lines).   It  also  describes  the
  977. general  structure, as a group of header lines, then a blank line, and
  978. then the body of the message.  Finally, it describes the syntax of the
  979. header  lines in detail.  Generally they consist of a keyword and then
  980. a value.
  981.  
  982. Note  that  the  addressee  is  indicated   as   LEVY@RED.RUTGERS.EDU.
  983. Initially,  addresses were simply "person at machine".  However recent
  984. standards have made things more flexible.  There  are  now  provisions
  985. for  systems  to handle other systems' mail.  This can allow automatic
  986. forwarding on behalf of computers not connected to the Internet.    It
  987. can be used to direct mail for a number of systems to one central mail
  988. server.  Indeed there is no requirement that an actual computer by the
  989. name  of RED.RUTGERS.EDU even exist.  The name servers could be set up
  990. so that you mail to department names, and each  department's  mail  is
  991. routed  automatically to an appropriate computer.  It is also possible
  992. that the part before the @ is something other than a user name.  It is
  993. possible  for  programs  to be set up to process mail.  There are also
  994. provisions  to  handle  mailing  lists,  and  generic  names  such  as
  995.                                   15
  996.  
  997.  
  998.  
  999. "postmaster" or "operator".
  1000.  
  1001. The  way  the  message is to be sent to another system is described by
  1002. RFC's 821 and 974.  The program that is going to be doing the  sending
  1003. asks  the  name server several queries to determine where to route the
  1004. message.  The first query is to find out which  machines  handle  mail
  1005. for  the  name RED.RUTGERS.EDU.  In this case, the server replies that
  1006. RED.RUTGERS.EDU handles its own mail.  The program then asks  for  the
  1007. address of RED.RUTGERS.EDU, which is 128.6.4.2.  Then the mail program
  1008. opens a TCP connection to port 25  on  128.6.4.2.    Port  25  is  the
  1009. well-known  socket  used  for receiving mail.  Once this connection is
  1010. established, the mail program starts sending  commands.    Here  is  a
  1011. typical  conversation.  Each line is labelled as to whether it is from
  1012. TOPAZ or RED.  Note that TOPAZ initiated the connection:
  1013.  
  1014.     RED    220 RED.RUTGERS.EDU SMTP Service at 29 Jun 87 05:17:18 EDT
  1015.     TOPAZ  HELO topaz.rutgers.edu
  1016.     RED    250 RED.RUTGERS.EDU - Hello, TOPAZ.RUTGERS.EDU
  1017.     TOPAZ  MAIL From:<hedrick@topaz.rutgers.edu>
  1018.     RED    250 MAIL accepted
  1019.     TOPAZ  RCPT To:<levy@red.rutgers.edu>
  1020.     RED    250 Recipient accepted
  1021.     TOPAZ  DATA
  1022.     RED    354 Start mail input; end with <CRLF>.<CRLF>
  1023.     TOPAZ  Date: Sat, 27 Jun 87 13:26:31 EDT
  1024.     TOPAZ  From: hedrick@topaz.rutgers.edu
  1025.     TOPAZ  To: levy@red.rutgers.edu
  1026.     TOPAZ  Subject: meeting
  1027.     TOPAZ
  1028.     TOPAZ  Let's get together Monday at 1pm.
  1029.     TOPAZ  .
  1030.     RED    250 OK
  1031.     TOPAZ  QUIT
  1032.     RED    221 RED.RUTGERS.EDU Service closing transmission channel
  1033.  
  1034. First, note that commands all use normal text.  This is typical of the
  1035. Internet  standards.    Many  of  the  protocols  use  standard  ASCII
  1036. commands.  This makes it easy  to  watch  what  is  going  on  and  to
  1037. diagnose  problems.  For example, the mail program keeps a log of each
  1038. conversation.  If something goes wrong, the log  file  can  simply  be
  1039. mailed  to  the  postmaster.  Since it is normal text, he can see what
  1040. was going on.  It also allows a human to interact  directly  with  the
  1041. mail  server,  for  testing.  (Some newer protocols are complex enough
  1042. that this is not practical.  The commands would have to have a  syntax
  1043. that would require a significant parser.  Thus there is a tendency for
  1044. newer protocols to use binary formats.  Generally they are  structured
  1045. like  C or Pascal record structures.)  Second, note that the responses
  1046. all begin with numbers.  This is also typical of  Internet  protocols.
  1047. The  allowable  responses  are  defined  in the protocol.  The numbers
  1048. allow the user program to respond unambiguously.    The  rest  of  the
  1049. response  is  text,  which is normally for use by any human who may be
  1050. watching or looking at a log.  It has no effect on  the  operation  of
  1051. the  programs.  (However there is one point at which the protocol uses
  1052. part of the text of the response.)   The  commands  themselves  simply
  1053. allow  the  mail  program  on  one  end  to  tell  the mail server the
  1054.                                   16
  1055.  
  1056.  
  1057.  
  1058. information it needs to know in order to deliver the message.  In this
  1059. case,  the  mail  server  could  get the information by looking at the
  1060. message itself.  But for more complex cases, that would not  be  safe.
  1061. Every  session  must  begin  with  a HELO, which gives the name of the
  1062. system that initiated the connection.  Then the sender and  recipients
  1063. are specified.  (There can be more than one RCPT command, if there are
  1064. several recipients.)  Finally the data itself is sent.  Note that  the
  1065. text  of the message is terminated by a line containing just a period.
  1066. (If such a line appears in the message, the period is doubled.)  After
  1067. the  message  is  accepted,  the  sender  can send another message, or
  1068. terminate the session as in the example above.
  1069.  
  1070. Generally, there is a pattern to the response numbers.   The  protocol
  1071. defines  the  specific set of responses that can be sent as answers to
  1072. any given command.  However programs that don't want to  analyze  them
  1073. in  detail  can  just  look at the first digit.  In general, responses
  1074. that begin with a 2  indicate  success.    Those  that  begin  with  3
  1075. indicate  that some further action is needed, as shown above.  4 and 5
  1076. indicate errors.  4 is a "temporary" error, such as  a  disk  filling.
  1077. The  message should be saved, and tried again later.  5 is a permanent
  1078. error, such as a  non-existent  recipient.    The  message  should  be
  1079. returned to the sender with an error message.
  1080.  
  1081. (For  more  details about the protocols mentioned in this section, see
  1082. RFC's 821/822 for mail, RFC 959 for file transfer, and  RFC's  854/855
  1083. for  remote  logins.  For the well-known port numbers, see the current
  1084. edition of Assigned Numbers, and possibly RFC 814.)
  1085.  
  1086.  
  1087.  
  1088. 4. Protocols other than TCP: UDP and ICMP
  1089.  
  1090.  
  1091. So far, we have described only connections that use TCP.  Recall  that
  1092. TCP  is  responsible  for  breaking  up  messages  into datagrams, and
  1093. reassembling them properly.  However in  many  applications,  we  have
  1094. messages  that  will  always  fit in a single datagram.  An example is
  1095. name lookup.  When a user attempts to make  a  connection  to  another
  1096. system,  he  will  generally  specify  the system by name, rather than
  1097. Internet address.  His system has to translate that name to an address
  1098. before  it  can  do  anything.  Generally, only a few systems have the
  1099. database used to translate names to addresses.  So the  user's  system
  1100. will want to send a query to one of the systems that has the database.
  1101. This query is going to be very short.  It will certainly  fit  in  one
  1102. datagram.    So  will the answer.  Thus it seems silly to use TCP.  Of
  1103. course TCP does more than just break things up  into  datagrams.    It
  1104. also  makes  sure  that  the  data  arrives, resending datagrams where
  1105. necessary.  But for a question that fits  in  a  single  datagram,  we
  1106. don't  need  all the complexity of TCP to do this.  If we don't get an
  1107. answer after a few seconds, we can just ask again.   For  applications
  1108. like this, there are alternatives to TCP.
  1109.  
  1110. The most common alternative is UDP ("user datagram protocol").  UDP is
  1111. designed for applications where you don't need  to  put  sequences  of
  1112. datagrams  together.  It fits into the system much like TCP.  There is
  1113.                                   17
  1114.  
  1115.  
  1116.  
  1117. a UDP header.  The network software puts the UDP header on  the  front
  1118. of  your  data, just as it would put a TCP header on the front of your
  1119. data.  Then UDP sends the data  to  IP,  which  adds  the  IP  header,
  1120. putting  UDP's  protocol number in the protocol field instead of TCP's
  1121. protocol number.  However UDP doesn't do as much  as  TCP  does.    It
  1122. doesn't  split data into multiple datagrams.  It doesn't keep track of
  1123. what it has sent so it can resend if necessary.  About  all  that  UDP
  1124. provides  is  port  numbers,  so  that several programs can use UDP at
  1125. once.  UDP port numbers are used just like TCP port  numbers.    There
  1126. are  well-known  port numbers for servers that use UDP.  Note that the
  1127. UDP header is shorter than a TCP header.   It  still  has  source  and
  1128. destination  port  numbers,  and  a checksum, but that's about it.  No
  1129. sequence number, since it is not needed.  UDP is used by the protocols
  1130. that  handle  name  lookups (see IEN 116, RFC 882, and RFC 883), and a
  1131. number of similar protocols.
  1132.  
  1133. Another  alternative  protocol  is  ICMP  ("Internet  control  message
  1134. protocol").    ICMP  is  used  for  error messages, and other messages
  1135. intended for the TCP/IP software itself, rather  than  any  particular
  1136. user  program.  For example, if you attempt to connect to a host, your
  1137. system may get back an ICMP message saying "host unreachable".    ICMP
  1138. can  also be used to find out some information about the network.  See
  1139. RFC 792 for details of ICMP.  ICMP is  similar  to  UDP,  in  that  it
  1140. handles messages that fit in one datagram.  However it is even simpler
  1141. than UDP.  It doesn't even have port numbers in its header.  Since all
  1142. ICMP  messages are interpreted by the network software itself, no port
  1143. numbers are needed to say where a ICMP message is supposed to go.
  1144.  
  1145.  
  1146.  
  1147. 5. Keeping track of names and information: the domain system
  1148.  
  1149.  
  1150. As we indicated earlier, the network software generally needs a 32-bit
  1151. Internet  address  in  order  to open a connection or send a datagram.
  1152. However users prefer to deal with computer names rather than  numbers.
  1153. Thus  there  is  a database that allows the software to look up a name
  1154. and find the corresponding number.  When the Internet was small,  this
  1155. was  easy.  Each system would have a file that listed all of the other
  1156. systems, giving both their name and number.  There are  now  too  many
  1157. computers  for  this  approach to be practical.  Thus these files have
  1158. been replaced by a set of name servers that keep track of  host  names
  1159. and  the corresponding Internet addresses.  (In fact these servers are
  1160. somewhat more general than that.  This is just one kind of information
  1161. stored in the domain system.)  Note that a set of interlocking servers
  1162. are used, rather than a single central one.  There  are  now  so  many
  1163. different  institutions  connected  to  the  Internet that it would be
  1164. impractical for them to  notify  a  central  authority  whenever  they
  1165. installed  or moved a computer.  Thus naming authority is delegated to
  1166. individual institutions.  The name servers form a tree,  corresponding
  1167. to  institutional  structure.    The names themselves follow a similar
  1168. structure.  A typical example is the name BORAX.LCS.MIT.EDU.  This  is
  1169. a  computer  at  the Laboratory for Computer Science (LCS) at MIT.  In
  1170. order to find its Internet address,  you  might  potentially  have  to
  1171. consult  4  different  servers.  First, you would ask a central server
  1172.                                   18
  1173.  
  1174.  
  1175.  
  1176. (called the root) where the EDU server is.  EDU is a server that keeps
  1177. track of educational institutions.  The root server would give you the
  1178. names and Internet addresses of several servers for EDU.   (There  are
  1179. several  servers  at  each  level,  to allow for the possibly that one
  1180. might be down.)  You would then ask EDU where the server for  MIT  is.
  1181. Again,  it  would  give  you  names  and Internet addresses of several
  1182. servers for MIT.  Generally, not all of those servers would be at MIT,
  1183. to  allow for the possibility of a general power failure at MIT.  Then
  1184. you would ask MIT where the server for LCS is, and finally  you  would
  1185. ask one of the LCS servers about BORAX.  The final result would be the
  1186. Internet address for BORAX.LCS.MIT.EDU.    Each  of  these  levels  is
  1187. referred  to  as  a  "domain".  The entire name, BORAX.LCS.MIT.EDU, is
  1188. called a "domain name".    (So  are  the  names  of  the  higher-level
  1189. domains, such as LCS.MIT.EDU, MIT.EDU, and EDU.)
  1190.  
  1191. Fortunately,  you  don't really have to go through all of this most of
  1192. the time.  First of all, the root name servers also happen to  be  the
  1193. name  servers  for  the  top-level domains such as EDU.  Thus a single
  1194. query to a root  server  will  get  you  to  MIT.    Second,  software
  1195. generally  remembers answers that it got before.  So once we look up a
  1196. name at LCS.MIT.EDU, our software remembers where to find servers  for
  1197. LCS.MIT.EDU,  MIT.EDU,  and EDU.  It also remembers the translation of
  1198. BORAX.LCS.MIT.EDU.  Each of these pieces of information has a "time to
  1199. live"  associated with it.  Typically this is a few days.  After that,
  1200. the information expires and has to be looked up again.    This  allows
  1201. institutions to change things.
  1202.  
  1203. The  domain  system  is not limited to finding out Internet addresses.
  1204. Each domain name is a node in a database.  The node can  have  records
  1205. that  define  a number of different properties.  Examples are Internet
  1206. address, computer type, and a list of services provided by a computer.
  1207. A  program  can  ask  for  a  specific  piece  of  information, or all
  1208. information about a given name.  It is possible  for  a  node  in  the
  1209. database  to  be  marked as an "alias" (or nickname) for another node.
  1210. It is also possible to use the  domain  system  to  store  information
  1211. about users, mailing lists, or other objects.
  1212.  
  1213. There  is  an  Internet  standard  defining  the  operation  of  these
  1214. databases, as well as the protocols used  to  make  queries  of  them.
  1215. Every  network utility has to be able to make such queries, since this
  1216. is now the official way to evaluate host names.   Generally  utilities
  1217. will talk to a server on their own system.  This server will take care
  1218. of contacting the other servers for them.  This keeps down the  amount
  1219. of code that has to be in each application program.
  1220.  
  1221. The  domain  system  is  particularly  important for handling computer
  1222. mail.  There are entry types to define what computer handles mail  for
  1223. a  given  name, to specify where an individual is to receive mail, and
  1224. to define mailing lists.
  1225.  
  1226. (See RFC's 882, 883, and 973 for specifications of the domain  system.
  1227. RFC 974 defines the use of the domain system in sending mail.)
  1228.  
  1229.  
  1230.  
  1231.                                   19
  1232.  
  1233.  
  1234.  
  1235. 6. Routing
  1236.  
  1237.  
  1238. The   description  above  indicated  that  the  IP  implementation  is
  1239. responsible for getting datagrams to the destination indicated by  the
  1240. destination address, but little was said about how this would be done.
  1241. The task of finding how to  get  a  datagram  to  its  destination  is
  1242. referred to as "routing".  In fact many of the details depend upon the
  1243. particular implementation.  However some general things can be said.
  1244.  
  1245. First, it is necessary to understand the model on which IP  is  based.
  1246. IP assumes that a system is attached to some local network.  We assume
  1247. that the system can send datagrams to any  other  system  on  its  own
  1248. network.    (In  the  case  of  Ethernet, it simply finds the Ethernet
  1249. address of the destination system, and puts the datagram  out  on  the
  1250. Ethernet.)    The  problem  comes  when  a  system  is asked to send a
  1251. datagram to a system on a different network.  This problem is  handled
  1252. by  gateways.   A gateway is a system that connects a network with one
  1253. or more other networks.  Gateways  are  often  normal  computers  that
  1254. happen  to have more than one network interface.  For example, we have
  1255. a Unix machine that has two different Ethernet interfaces.  Thus it is
  1256. connected  to networks 128.6.4 and 128.6.3.  This machine can act as a
  1257. gateway between those two networks.  The software on that machine must
  1258. be  set  up  so that it will forward datagrams from one network to the
  1259. other.  That is, if a machine on network 128.6.4 sends a  datagram  to
  1260. the  gateway,  and  the  datagram is addressed to a machine on network
  1261. 128.6.3, the gateway will forward the  datagram  to  the  destination.
  1262. Major communications centers often have gateways that connect a number
  1263. of different  networks.    (In  many  cases,  special-purpose  gateway
  1264. systems provide better performance or reliability than general-purpose
  1265. systems acting as gateways.  A number of vendors sell such systems.)
  1266.  
  1267. Routing in IP is  based  entirely  upon  the  network  number  of  the
  1268. destination  address.    Each computer has a table of network numbers.
  1269. For each network number, a gateway is listed.  This is the gateway  to
  1270. be used to get to that network.  Note that the gateway doesn't have to
  1271. connect directly to the network.  It just has to be the best place  to
  1272. go  to  get there.  For example at Rutgers, our interface to NSFnet is
  1273. at the John von Neuman Supercomputer Center (JvNC). Our connection  to
  1274. JvNC  is  via  a  high-speed  serial line connected to a gateway whose
  1275. address is 128.6.3.12.  Systems on net 128.6.3 will list 128.6.3.12 as
  1276. the  gateway  for  many  off-campus  networks.  However systems on net
  1277. 128.6.4 will list 128.6.4.1 as the gateway to  those  same  off-campus
  1278. networks.    128.6.4.1  is  the  gateway  between networks 128.6.4 and
  1279. 128.6.3, so it is the first step in getting to JvNC.
  1280.  
  1281. When a computer wants to send a datagram, it first checks  to  see  if
  1282. the  destination address is on the system's own local network.  If so,
  1283. the datagram can be sent directly.  Otherwise, the system  expects  to
  1284. find an entry for the network that the destination address is on.  The
  1285. datagram is sent to the gateway listed in that entry.  This table  can
  1286. get quite big.  For example, the Internet now includes several hundred
  1287. individual networks.  Thus various strategies have been  developed  to
  1288. reduce  the size of the routing table.  One strategy is to depend upon
  1289. "default routes".  Often, there is only one gateway out of a  network.
  1290.                                   20
  1291.  
  1292.  
  1293.  
  1294. This  gateway might connect a local Ethernet to a campus-wide backbone
  1295. network.  In that case, we don't need to have  a  separate  entry  for
  1296. every  network  in  the  world.    We  simply define that gateway as a
  1297. "default".  When no specific  route  is  found  for  a  datagram,  the
  1298. datagram  is  sent to the default gateway.  A default gateway can even
  1299. be used when there are several gateways  on  a  network.    There  are
  1300. provisions  for  gateways  to  send a message saying "I'm not the best
  1301. gateway -- use this one instead."  (The message is sent via ICMP.  See
  1302. RFC  792.)  Most network software is designed to use these messages to
  1303. add entries to their routing tables.  Suppose network 128.6.4 has  two
  1304. gateways, 128.6.4.59 and 128.6.4.1.  128.6.4.59 leads to several other
  1305. internal Rutgers networks.  128.6.4.1 leads indirectly to the  NSFnet.
  1306. Suppose  we  set  128.6.4.59  as  a default gateway, and have no other
  1307. routing table entries.  Now what  happens  when  we  need  to  send  a
  1308. datagram  to  MIT?    MIT  is  network 18.  Since we have no entry for
  1309. network 18, the datagram will be sent to the default, 128.6.4.59.   As
  1310. it  happens,  this  gateway  is the wrong one.  So it will forward the
  1311. datagram to 128.6.4.1.  But it will also send back an error saying  in
  1312. effect: "to get to network 18, use 128.6.4.1".  Our software will then
  1313. add an entry to the routing table.  Any future datagrams to  MIT  will
  1314. then  go  directly to 128.6.4.1.  (The error message is sent using the
  1315. ICMP protocol.  The message type is called "ICMP redirect.")
  1316.  
  1317. Most IP experts recommend that individual computers should not try  to
  1318. keep  track  of  the  entire network.  Instead, they should start with
  1319. default gateways, and let the gateways tell them the routes,  as  just
  1320. described.   However this doesn't say how the gateways should find out
  1321. about the routes.  The gateways can't depend upon this strategy.  They
  1322. have  to  have fairly complete routing tables.  For this, some sort of
  1323. routing protocol is needed.  A routing protocol is simply a  technique
  1324. for  the  gateways  to  find each other, and keep up to date about the
  1325. best way to get to every network.   RFC  1009  contains  a  review  of
  1326. gateway  design  and  routing.    However rip.doc is probably a better
  1327. introduction to the subject.  It contains some tutorial material,  and
  1328. a detailed description of the most commonly-used routing protocol.
  1329.  
  1330.  
  1331.  
  1332. 7. Details about Internet addresses: subnets and broadcasting
  1333.  
  1334.  
  1335. As  indicated earlier, Internet addresses are 32-bit numbers, normally
  1336. written as 4 octets (in decimal), e.g. 128.6.4.7.  There are  actually
  1337. 3  different types of address.  The problem is that the address has to
  1338. indicate both the network and the host within the  network.    It  was
  1339. felt  that  eventually  there would be lots of networks.  Many of them
  1340. would be small, but probably 24 bits would be needed to represent  all
  1341. the  IP  networks.  It was also felt that some very big networks might
  1342. need 24 bits to represent all of their hosts.  This would seem to lead
  1343. to  48  bit  addresses.  But the designers really wanted to use 32 bit
  1344. addresses.  So they adopted a kludge.  The assumption is that most  of
  1345. the  networks will be small.  So they set up three different ranges of
  1346. address.  Addresses beginning with 1 to 126 use only the  first  octet
  1347. for  the network number.  The other three octets are available for the
  1348. host number.  Thus 24 bits are available for hosts.  These numbers are
  1349.                                   21
  1350.  
  1351.  
  1352.  
  1353. used  for large networks.  But there can only be 126 of these very big
  1354. networks.  The Arpanet is one, and there are a  few  large  commercial
  1355. networks.    But  few  normal organizations get one of these "class A"
  1356. addresses.  For normal large organizations, "class  B"  addresses  are
  1357. used.    Class  B  addresses  use the first two octets for the network
  1358. number.  Thus network numbers are 128.1 through 191.254.  (We avoid  0
  1359. and  255,  for  reasons  that  we  see below.  We also avoid addresses
  1360. beginning with 127, because that is used by some systems  for  special
  1361. purposes.)    The  last  two  octets  are available for host addesses,
  1362. giving 16 bits of host address.   This  allows  for  64516  computers,
  1363. which should be enough for most organizations.  (It is possible to get
  1364. more than one class B address, if you run  out.)    Finally,  class  C
  1365. addresses  use  three  octets,  in  the  range 192.1.1 to 223.254.254.
  1366. These allow only 254 hosts on each network, but there can be  lots  of
  1367. these  networks.   Addresses above 223 are reserved for future use, as
  1368. class D and E (which are currently not defined).
  1369.  
  1370. Many large organizations find it convenient to  divide  their  network
  1371. number into "subnets".  For example, Rutgers has been assigned a class
  1372. B address, 128.6.  We find it convenient to use the third octet of the
  1373. address to indicate which Ethernet a host is on.  This division has no
  1374. significance outside of Rutgers.  A computer  at  another  institution
  1375. would treat all datagrams addressed to 128.6 the same way.  They would
  1376. not look at the third octet of the address.   Thus  computers  outside
  1377. Rutgers  would  not have different routes for 128.6.4 or 128.6.5.  But
  1378. inside Rutgers, we treat 128.6.4 and 128.6.5 as separate networks.  In
  1379. effect, gateways inside Rutgers have separate entries for each Rutgers
  1380. subnet, whereas gateways outside  Rutgers  just  have  one  entry  for
  1381. 128.6.  Note  that  we  could  do  exactly  the  same thing by using a
  1382. separate class C address for each Ethernet.   As  far  as  Rutgers  is
  1383. concerned,  it  would be just as convenient for us to have a number of
  1384. class C addresses.  However using class C addresses would make  things
  1385. inconvenient for the rest of the world.  Every institution that wanted
  1386. to talk to us would have to have a separate entry for each one of  our
  1387. networks.   If every institution did this, there would be far too many
  1388. networks for any reasonable gateway to keep track of.  By  subdividing
  1389. a  class B network, we hide our internal structure from everyone else,
  1390. and  save  them  trouble.    This  subnet  strategy  requires  special
  1391. provisions in the network software.  It is described in RFC 950.
  1392.  
  1393. 0  and  255  have  special  meanings.  0 is reserved for machines that
  1394. don't know their address.  In certain circumstances it is possible for
  1395. a  machine not to know the number of the network it is on, or even its
  1396. own host address.  For example, 0.0.0.23 would be a machine that  knew
  1397. it was host number 23, but didn't know on what network.
  1398.  
  1399. 255  is  used for "broadcast".  A broadcast is a message that you want
  1400. every system on the network to see.    Broadcasts  are  used  in  some
  1401. situations  where you don't know who to talk to.  For example, suppose
  1402. you need to look  up  a  host  name  and  get  its  Internet  address.
  1403. Sometimes  you  don't know the address of the nearest name server.  In
  1404. that case, you might send the request as a broadcast.  There are  also
  1405. cases  where a number of systems are interested in information.  It is
  1406. then less expensive to send a single broadcast than to send  datagrams
  1407. individually  to  each host that is interested in the information.  In
  1408.                                   22
  1409.  
  1410.  
  1411.  
  1412. order to send a broadcast, you use an address that is  made  by  using
  1413. your  network  address, with all ones in the part of the address where
  1414. the host number goes.  For example, if you are on network 128.6.4, you
  1415. would   use   128.6.4.255  for  broadcasts.    How  this  is  actually
  1416. implemented depends upon the medium.   It  is  not  possible  to  send
  1417. broadcasts  on the Arpanet, or on point to point lines.  However it is
  1418. possible on an Ethernet.  If you use an Ethernet address with all  its
  1419. bits  on (all ones), every machine on the Ethernet is supposed to look
  1420. at that datagram.
  1421.  
  1422. Although the official broadcast address for  network  128.6.4  is  now
  1423. 128.6.4.255,  there  are  some  other addresses that may be treated as
  1424. broadcasts by certain implementations.  For convenience, the  standard
  1425. also  allows  255.255.255.255 to be used.  This refers to all hosts on
  1426. the local network.  It is often simpler to use 255.255.255.255 instead
  1427. of  finding out the network number for the local network and forming a
  1428. broadcast address such as 128.6.4.255.   In  addition,  certain  older
  1429. implementations  may  use  0  instead  of  255  to  form the broadcast
  1430. address.    Such  implementations  would  use  128.6.4.0  instead   of
  1431. 128.6.4.255  as  the  broadcast  address on network 128.6.4.  Finally,
  1432. certain older implementations may not understand about subnets.   Thus
  1433. they consider the network number to be 128.6.  In that case, they will
  1434. assume a broadcast address  of  128.6.255.255  or  128.6.0.0.    Until
  1435. support  for  broadcasts is implemented properly, it can be a somewhat
  1436. dangerous feature to use.
  1437.  
  1438. Because 0 and 255 are used for unknown and broadcast addresses, normal
  1439. hosts  should never be given addresses containing 0 or 255.  Addresses
  1440. should never begin with 0, 127, or any number above  223.    Addresses
  1441. violating these rules are sometimes referred to as "Martians", because
  1442. of rumors that the Central University of Mars is using network 225.
  1443.  
  1444.  
  1445.  
  1446. 8. Datagram fragmentation and reassembly
  1447.  
  1448.  
  1449. TCP/IP is designed for use  with  many  different  kinds  of  network.
  1450. Unfortunately,  network  designers  do not agree about how big packets
  1451. can be.  Ethernet packets can be 1500 octets long.    Arpanet  packets
  1452. have  a  maximum  of around 1000 octets.  Some very fast networks have
  1453. much larger packet sizes.  At first, you might think  that  IP  should
  1454. simply  settle  on  the  smallest  possible size.  Unfortunately, this
  1455. would cause serious performance problems.    When  transferring  large
  1456. files, big packets are far more efficient than small ones.  So we want
  1457. to be able to use the largest packet size possible.  But we also  want
  1458. to  be  able  to  handle  networks  with  small limits.  There are two
  1459. provisions for this.  First, TCP has the ability to "negotiate"  about
  1460. datagram  size.  When a TCP connection first opens, both ends can send
  1461. the maximum datagram size they can  handle.    The  smaller  of  these
  1462. numbers  is  used  for  the  rest  of the connection.  This allows two
  1463. implementations that can handle big datagrams to use  them,  but  also
  1464. lets  them  talk  to  implementations that can't handle them.  However
  1465. this doesn't completely solve the problem.  The most  serious  problem
  1466. is  that the two ends don't necessarily know about all of the steps in
  1467.                                   23
  1468.  
  1469.  
  1470.  
  1471. between.  For example, when sending data between Rutgers and Berkeley,
  1472. it is likely that both computers will be on Ethernets.  Thus they will
  1473. both  be  prepared  to  handle  1500-octet  datagrams.    However  the
  1474. connection will at some point end up going over the Arpanet.  It can't
  1475. handle packets of that size.  For this reason, there are provisions to
  1476. split   datagrams   up   into   pieces.    (This  is  referred  to  as
  1477. "fragmentation".)  The IP header  contains  fields  indicating  the  a
  1478. datagram  has  been split, and enough information to let the pieces be
  1479. put back together.  If a gateway connects an Ethernet to the  Arpanet,
  1480. it must be prepared to take 1500-octet Ethernet packets and split them
  1481. into pieces that will fit on the Arpanet.    Furthermore,  every  host
  1482. implementation  of  TCP/IP  must  be prepared to accept pieces and put
  1483. them back together.  This is referred to as "reassembly".
  1484.  
  1485. TCP/IP implementations differ in the approach they take to deciding on
  1486. datagram  size.    It  is  fairly  common  for  implementations to use
  1487. 576-byte datagrams whenever they can't verify that the entire path  is
  1488. able  to  handle larger packets.  This rather conservative strategy is
  1489. used because of the number of implementations with bugs in the code to
  1490. reassemble  fragments.    Implementors  often try to avoid ever having
  1491. fragmentation occur.  Different implementors take different approaches
  1492. to  deciding  when  it  is safe to use large datagrams.  Some use them
  1493. only for the local network.  Others will use them for any  network  on
  1494. the   same   campus.    576  bytes  is  a  "safe"  size,  which  every
  1495. implementation must support.
  1496.  
  1497.  
  1498.  
  1499. 9. Ethernet encapsulation: ARP
  1500.  
  1501.  
  1502. There was a brief discussion earlier about what IP datagrams look like
  1503. on  an  Ethernet.    The  discussion  showed  the  Ethernet header and
  1504. checksum.  However it left one hole: It didn't say how to  figure  out
  1505. what Ethernet address to use when you want to talk to a given Internet
  1506. address.  In fact, there is a separate protocol for this,  called  ARP
  1507. ("address  resolution protocol").  (Note by the way that ARP is not an
  1508. IP protocol.  That is, the ARP datagrams  do  not  have  IP  headers.)
  1509. Suppose  you  are  on  system  128.6.4.194  and you want to connect to
  1510. system 128.6.4.7.  Your system will first verify that 128.6.4.7 is  on
  1511. the  same network, so it can talk directly via Ethernet.  Then it will
  1512. look up 128.6.4.7 in its ARP table, to see if  it  already  knows  the
  1513. Ethernet  address.    If  so, it will stick on an Ethernet header, and
  1514. send the packet.  But suppose this system is not  in  the  ARP  table.
  1515. There  is  no  way  to  send the packet, because you need the Ethernet
  1516. address.  So it  uses  the  ARP  protocol  to  send  an  ARP  request.
  1517. Essentially  an  ARP  request  says  "I  need the Ethernet address for
  1518. 128.6.4.7".  Every system listens to ARP requests.  When a system sees
  1519. an  ARP  request  for itself, it is required to respond.  So 128.6.4.7
  1520. will see the request, and will respond with an  ARP  reply  saying  in
  1521. effect "128.6.4.7 is 8:0:20:1:56:34".  (Recall that Ethernet addresses
  1522. are 48 bits.  This is 6 octets.  Ethernet addresses are conventionally
  1523. shown  in  hex,  using  the punctuation shown.)  Your system will save
  1524. this information in its ARP table, so future packets will go directly.
  1525. Most  systems  treat the ARP table as a cache, and clear entries in it
  1526.                                   24
  1527.  
  1528.  
  1529.  
  1530. if they have not been used in a certain period of time.
  1531.  
  1532. Note by the way that ARP requests must be sent as "broadcasts".  There
  1533. is  no  way  that  an  ARP  request  can be sent directly to the right
  1534. system.  After all, the whole reason for sending  an  ARP  request  is
  1535. that  you  don't know the Ethernet address.  So an Ethernet address of
  1536. all ones is  used,  i.e.  ff:ff:ff:ff:ff:ff.    By  convention,  every
  1537. machine  on  the Ethernet is required to pay attention to packets with
  1538. this as an address.  So every system sees every ARP  requests.    They
  1539. all  look to see whether the request is for their own address.  If so,
  1540. they respond.  If not, they could just ignore it.   (Some  hosts  will
  1541. use  ARP  requests  to update their knowledge about other hosts on the
  1542. network, even if the request isn't for them.)  Note that packets whose
  1543. IP  address  indicates broadcast (e.g. 255.255.255.255 or 128.6.4.255)
  1544. are also sent with an Ethernet address that is all ones.
  1545.  
  1546.  
  1547.  
  1548. 10. Getting more information
  1549.  
  1550.  
  1551. This directory contains  documents  describing  the  major  protocols.
  1552. There  are literally hundreds of documents, so we have chosen the ones
  1553. that seem most important.  Internet standards are called RFC's.    RFC
  1554. stands  for  Request  for  Comment.   A proposed standard is initially
  1555. issued as a proposal, and given an RFC number.   When  it  is  finally
  1556. accepted,  it is added to Official Internet Protocols, but it is still
  1557. referred to by the RFC number.   We  have  also  included  two  IEN's.
  1558. (IEN's  used  to  be  a  separate  classification  for  more  informal
  1559. documents.  This classification no longer exists -- RFC's are now used
  1560. for  all  official  Internet documents, and a mailing list is used for
  1561. more informal reports.)  The convention is that  whenever  an  RFC  is
  1562. revised, the revised version gets a new number.  This is fine for most
  1563. purposes, but it causes problems with two documents: Assigned  Numbers
  1564. and  Official  Internet  Protocols.  These documents are being revised
  1565. all the time, so the RFC number keeps changing.  You will have to look
  1566. in rfc-index.txt to find the number of the latest edition.  Anyone who
  1567. is seriously interested in TCP/IP should read the  RFC  describing  IP
  1568. (791).    RFC 1009 is also useful.  It is a specification for gateways
  1569. to be used by NSFnet.  As such, it contains an overview of  a  lot  of
  1570. the  TCP/IP technology.  You should probably also read the description
  1571. of at least one of the application protocols, just to get a  feel  for
  1572. the  way  things  work.    Mail is probably a good one (821/822).  TCP
  1573. (793) is of course a very basic specification.  However  the  spec  is
  1574. fairly  complex,  so  you should only read this when you have the time
  1575. and patience to think about it carefully.  Fortunately, the author  of
  1576. the  major  RFC's  (Jon Postel) is a very good writer.  The TCP RFC is
  1577. far easier to read than you would expect, given the complexity of what
  1578. it  is  describing.    You  can  look at the other RFC's as you become
  1579. curious about their subject matter.
  1580.  
  1581. Here is a list of the documents you are more likely to want:
  1582.  
  1583.      rfc-index list of all RFC's
  1584.  
  1585.                                   25
  1586.  
  1587.  
  1588.  
  1589.      rfc1012   somewhat fuller list of all RFC's
  1590.  
  1591.      rfc1011   Official Protocols.  It's useful to scan  this  to  see
  1592.                what tasks protocols have been built for.  This defines
  1593.                which  RFC's  are  actual  standards,  as  opposed   to
  1594.                requests for comments.
  1595.  
  1596.      rfc1010   Assigned  Numbers.  If you are working with TCP/IP, you
  1597.                will probably want a hardcopy of this as  a  reference.
  1598.                It's  not  very  exciting  to  read.   It lists all the
  1599.                offically defined well-known ports and  lots  of  other
  1600.                things.
  1601.  
  1602.      rfc1009   NSFnet  gateway  specifications.  A good overview of IP
  1603.                routing and gateway technology.
  1604.  
  1605.      rfc1001/2 netBIOS: networking for PC's
  1606.  
  1607.      rfc973    update on domains
  1608.  
  1609.      rfc959    FTP (file transfer)
  1610.  
  1611.      rfc950    subnets
  1612.  
  1613.      rfc937    POP2: protocol for reading mail on PC's
  1614.  
  1615.      rfc894    how IP is to be put on Ethernet, see also rfc825
  1616.  
  1617.      rfc882/3  domains (the database used to go  from  host  names  to
  1618.                Internet  address  and back -- also used to handle UUCP
  1619.                these days).  See also rfc973
  1620.  
  1621.      rfc854/5  telnet - protocol for remote logins
  1622.  
  1623.      rfc826    ARP - protocol for finding out Ethernet addresses
  1624.  
  1625.      rfc821/2  mail
  1626.  
  1627.      rfc814    names and ports - general  concepts  behind  well-known
  1628.                ports
  1629.  
  1630.      rfc793    TCP
  1631.  
  1632.      rfc792    ICMP
  1633.  
  1634.      rfc791    IP
  1635.  
  1636.      rfc768    UDP
  1637.  
  1638.      rip.doc   details of the most commonly-used routing protocol
  1639.  
  1640.      ien-116   old  name  server  (still  needed  by  several kinds of
  1641.                system)
  1642.  
  1643.      ien-48    the  Catenet  model,   general   description   of   the
  1644.                                   26
  1645.  
  1646.  
  1647.  
  1648.                philosophy behind TCP/IP
  1649.  
  1650. The following documents are somewhat more specialized.
  1651.  
  1652.      rfc813    window and acknowledgement strategies in TCP
  1653.  
  1654.      rfc815    datagram reassembly techniques
  1655.  
  1656.      rfc816    fault isolation and resolution techniques
  1657.  
  1658.      rfc817    modularity and efficiency in implementation
  1659.  
  1660.      rfc879    the maximum segment size option in TCP
  1661.  
  1662.      rfc896    congestion control
  1663.  
  1664.      rfc827,888,904,975,985
  1665.                EGP and related issues
  1666.  
  1667. To those of you who may be reading this document remotely  instead  of
  1668. at  Rutgers:  The  most  important  RFC's  have  been collected into a
  1669. three-volume set, the DDN Protocol Handbook.  It is available from the
  1670. DDN  Network  Information  Center,  SRI  International, 333 Ravenswood
  1671. Avenue, Menlo Park, California 94025 (telephone: 800-235-3155).    You
  1672. should  be able to get them via anonymous FTP from sri-nic.arpa.  File
  1673. names are:
  1674.  
  1675.   RFC's:
  1676.     rfc:rfc-index.txt
  1677.     rfc:rfcxxx.txt
  1678.   IEN's:
  1679.     ien:ien-index.txt
  1680.     ien:ien-xxx.txt
  1681.  
  1682. rip.doc is available  by  anonymous  FTP  from  topaz.rutgers.edu,  as
  1683. /pub/tcp-ip-docs/rip.doc.
  1684.  
  1685. Sites with access to UUCP but not FTP may be able to retreive them via
  1686. UUCP from UUCP host rutgers.  The file names would be
  1687.  
  1688.   RFC's:
  1689.     /topaz/pub/pub/tcp-ip-docs/rfc-index.txt
  1690.     /topaz/pub/pub/tcp-ip-docs/rfcxxx.txt
  1691.   IEN's:
  1692.     /topaz/pub/pub/tcp-ip-docs/ien-index.txt
  1693.     /topaz/pub/pub/tcp-ip-docs/ien-xxx.txt
  1694.   /topaz/pub/pub/tcp-ip-docs/rip.doc
  1695.  
  1696. Note that SRI-NIC has the entire set of RFC's and IEN's,  but  rutgers
  1697. and topaz have only those specifically mentioned above.
  1698.  
  1699.  
  1700.  
  1701.  
  1702.  
  1703.                                   27
  1704.